import axios from 'axios';
import { requestBegin, requestEnd } from './actionCommon';
import { buildUrl } from '../config/httpConfig';
// export const GET_GOODS = 'GET_GOODS';
export const BUILD_RECEIVED = 'BUILD_RECEIVED';
export const BUILD_INIT = 'BUILD_INIT';
axios.defaults.withCredentials = true;
export function getBuild (option) {
    return (dispatch) => {
        dispatch(requestBegin('isFetching'));
        return axios.get(buildUrl, {
            params: option.query,
        })
            .then((res) => {
                dispatch(buildReceived({
                    list: res.data,
                }));
                dispatch(requestEnd('success'));
            })
            .catch(err => {
                if (err) {
                    dispatch(requestEnd('err'));
                }
            });
    };
}
export function buildReceived (data) {
    return {
        type: BUILD_RECEIVED,
        build: data.list,
    };
}
export function buildInit (data) {
    return {
        type: BUILD_INIT,
        build: data,
    };
}
